<%@ page import="java.util.List" %>
<%@ page import="com.huang.info.UserInfo" %><%--
  Created by IntelliJ IDEA.
  User: Jimmy
  Date: 2022/4/29
  Time: 11:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>

  <title>Title</title>

  <style type="text/css">
    legend{font-size: 12pt; color: black;}
  </style>

  <script src="<%=request.getContextPath()%>/js/jimmyhuang.js" type="text/javascript" charset="utf-8"></script>

  <script type="text/javascript">

    $(function (){

      /**
       * 退出登录
       */
      $("#loginOut").click(function (){

        //跳转到LoginOutServlet
        window.location.href = "<%=request.getContextPath()%>/loginOut"

      })

      /**
       * 删除操作
       */
      $(".delete").click(function (){

        //选中当前行
        var tr = $(this).closest("tr");
        //当前行的第一列
        var id = tr.find("td:eq(0)").html();

        var flag = window.confirm("是否确认删除？");

        if (flag) {
          window.location.href = "<%=request.getContextPath()%>/del?id="+id;
        }

      })

      $(".edit").click(function (){

        //选中当前行
        var tr = $(this).closest("tr");
        //当前行的第一列
        var id = tr.find("td:eq(0)").html();

        var flag = window.confirm("是否确认修改？");

        if (flag) {
          window.location.href = "<%=request.getContextPath()%>/Update?id="+id;
        }

      })

    })

  </script>
</head>
<body>
<tr>
  <td>欢迎登陆：<span style="color: red">${userInfo.phone}</span></td>
  <td><a id="loginOut">退出登陆</a></td>
</tr>

<form action="" method="post" id="main1">
  <fieldset id="field">
    <legend>所有用户-></legend>
    <table border="0" cellpadding="10">
      <%--表头--%>
      <tr>
        <td><b>No.</b></td>
        <td><b>Phone/Name</b></td>
        <td><b>Password</b></td>
        <td><b>Sex</b></td>
        <td><b>Hobby</b></td>
        <td><b>Age</b></td>
        <td><b>Header</b></td>
        <td><b>Education</b></td>
        <td><b>Myself</b></td>
        <td><b>操作</b></td>
      </tr>

<%--  jstl 来遍历数据，对EL表达式的扩展--%>
       <%
       session.getAttribute("userList");
       %>

        <c:forEach var="user" items="${userList}">

          <tr>
            <td><c:out value="${user.id}"></c:out> </td>
            <td><c:out value="${user.phone}"></c:out></td>
            <td><c:out value="${user.password}"></c:out></td>
            <td><c:out value="${user.sex}"></c:out></td>
            <td><c:out value="${user.hobby}"></c:out></td>
            <td><c:out value="${user.age}"></c:out></td>
            <td><c:out value="${user.header}"></c:out></td>
            <td><c:out value="${user.education}"></c:out></td>
            <td><c:out value="${user.myself}"></c:out></td>
            <td><input type="button" class="edit" value="编  辑">
              <input type="button" class="delete" value="删  除">
            </td>
          </tr>
        </c:forEach>


    </table>
  </fieldset>
</form>
</body>
</html>
